package main

import "fmt"

func main() {
	//breakFunc()
	//breakOuter()
	//breakOuter2()
	//continueFunc()
	//continueFunc2()
	//gotoFunc()
	gotoFunc2()
}

func breakFunc() {
	for i := 0; i < 10; i++ {
		if i == 5 {
			break
		}
		fmt.Println(i)
	}
}

func breakOuter() {
	fmt.Println("---breakOuter----------")
outer:
	switch num := 1; num {
	case 1:
		fmt.Println(1)
	case 2:
		fmt.Println(2)
		break outer
	default:
		fmt.Println("other")
	}
	fmt.Println("come here")
}

func breakOuter2() {
	fmt.Println("---breakOuter2----------")
outer:
	for i := 0; i < 5; i++ {
		for j := 0; j < 10; j++ {
			if j == 5 {
				break outer
			}
			fmt.Println(j)
		}
	}
	fmt.Println("come here")
}

func continueFunc() {
	for i := 0; i < 5; i++ {
		if i == 2 {
			continue
		}
		fmt.Println(i)
	}
}

func continueFunc2() {
outer:
	for i := 0; i < 5; i++ {
		fmt.Println("i = ", i)
		for j := 0; j < 10; j++ {
			if j == 5 {
				continue outer
			}
		}
	}
	fmt.Println("come here")
}

func gotoFunc() {
	num := 1
outer:
	if num < 10 {
		fmt.Println(num)
		num++
		goto outer
	}
	fmt.Println("come here")
}

func gotoFunc2() {
	num := 1
	if num < 10 {
		fmt.Println(num)
		num++
		goto outer
	}
outer:
	fmt.Println("come here")
}
